package com.example.leetcode.graph;

import com.example.leetcode.graph.common.GraphUtils;
import com.example.leetcode.tree.common.TreeNode;
import com.example.leetcode.tree.common.TreeUtils;

import java.util.List;

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 * int val;
 * TreeNode left;
 * TreeNode right;
 * TreeNode(int x) { val = x; }
 * }
 */
class Solution863 {
    public List<Integer> distanceK(TreeNode root, TreeNode target, int k) {
        return GraphUtils.distanceK(root, target, k);
    }
}

public class leetcode863 {
    public static void main(String[] args) {
        Solution863 solution863 = new Solution863();
        Integer[] nums = {3, 5, 1, 6, 2, 0, 8, null, null, 7, 4};
        int target = 5;
        int k = 2;
        test863(solution863, nums, target, k);
    }

    private static void test863(Solution863 solution863, Integer[] nums, int target, int k) {
        TreeNode root = TreeUtils.generateLeetcodeTree(nums);
        TreeNode treeNode = TreeUtils.getTreeNodeByVal(root, target);
        System.out.println(solution863.distanceK(root, treeNode, k));
    }
}
